import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Device } from 'src/entities/Device';
import { DeviceRecord } from 'src/types';
import { Repository } from 'typeorm';

@Injectable()
export class DeviceService {
    constructor(
        @InjectRepository(Device) protected repository:Repository<Device>
    ){}

    async device(deviceId:number, fields?:(keyof Device)[]) {
        let device:DeviceRecord = await this.repository.findOne(deviceId, {
            select : fields
        })

        return device
    }
}
